import math
import threading
import random
import time
def Fibo(n):
		fib1= b =1
		fib = 2
		if n==1:
			return True
		while fib1 + b <= n:
			fib = fib1 + b
			b = fib1
			fib1 = fib
		if (fib==n) :
			return True
		return False

def coroutine(func):
    def start(*args,**kwargs):
        cr = func(*args,**kwargs)
        cr.next()
        return cr
    return start

def producer():
    time.sleep(1)
    rand = random.randint(1,1000)
    a = consumer(rand)
    a.send(rand)

if __name__ == '__main__':
    @coroutine
    def consumer(rand):
        print "Kiem tra so ",rand
        while 1:
            num = (yield)
            if Fibo(num):
                print "So %d thuoc day fibonacci\n" %num
            else:
                print "So %d khong thuoc day fibonacci\n" %num
  
while(1):
    producer()